<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>订单状态</title>
        <script language="javascript" type="text/javascript" src="{res file=js/jquery-1.2.6.js}"></script>
        <script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>
        <script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
        <script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
        <script language="javascript" type="text/javascript" src="{lib file=ajaxfileupload.js}"></script>
        <script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>
        <script language="JavaScript" type="text/javascript" src="{res file=js/lan.js}"></script>
        <link href="template/style/css/style.css" type="text/css" rel="stylesheet" />
        <style>
            label.error {color:red;}
        </style>
    </head>
    <body>
        <div class="sub-body">
            <h3 class="title-1">大货情况</h3>
            <div class="tab-frame">
                <div class="tab-title-1"><span>大货情况</span></div>
                <form action="{$site_url}/index.php?app=order&act=order_status" method="post" id="status_form">
                    <table cellspacing="0" cellpadding="0" id="tab-color1" class="tab-add">
                        <tbody>
                            <tr>
                                <th>订单号</th>
                                <td align="left">
                                    {$order.order_sn}
                                </td>
                                <th>款号</th>
                                <td align="left">{$order.style_sn}</td>
                                <th>状态</th>
                                <td align="left">{$lang.order_status.$order.status}</td>
                            </tr>
                            <tr>
                                <th>剩余天数</th>
                                <td align="left"><font color="#ff0000">{$order.left_days}</font></td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>参 考 板</th>
                                <td align="left"><input type="text" name="info[ref_sample]" id="ref_sample" class="input-2" value="{$order.ref_sample|escape}" /></td>
                                <th>到板日期</th>
                                <td align="left">
                                    <input type="text" name="info[arrival_date]" class="input-1" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{$order.arrival_date|date}"/>
                                </td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>生产板/价格</th>
                                <td align="left"><input type="text" name="info[made_price]" id="made_price" class="input-3" value="{$order.made_price|escape}" /></td>
								<td>色卡/色号</td>
                                <td colspan="3" align="left"><input type="text" name="info[color_card]" id="color_card" class="input-3" value="{$order.color_card|escape}" /></td>
                            </tr>
                            <tr>
                                <th>PP&nbsp;&nbsp;&nbsp;&nbsp;板</th><td colspan="5" align="left"><select id="p_zaiban">
                                        <option value="1">是</option>
                                        <option value="0">否</option> </select></td></tr>
                             <!--{if $can_add_pp || 1}-->
                            <tr><th >序号</th><td colspan="5" align="left"><select name="pp_number" id="pp_number">
                                        <!--{foreach from=$lang.pp_number item=p key=k}-->
                                        <option value="{$p}">{$p}</option>
                                        <!--{/foreach}-->
                                    </select></td></tr>
                            <tr><th >寄板日期</th><td colspan="5" align="left"><input type="text" id="pp_date" name="pinfo[date]" class="input-1" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
                                </td></tr>
                            <tr> <th>价格</th><td colspan="5" align="left"><input type="text" class="input-1" id="pp_price" /></td></tr>
                            <tr><th>是否再板</th><td colspan="5" align="left">
                                    <select id="pp_zaiban">
                                        <option value="1">是</option>
                                        <option value="0">否</option>
                                    </select>&nbsp;&nbsp;</td></tr>
                            <tr><th >备注</th><td colspan="5" align="left"><textarea id="pp_remark" name="pp_remark" cols="60" rows="6"></textarea>
                                    <input type="button" value="添加" onclick="addPP();return false;" class="btn-1"  id="pp_add_bt"/>&nbsp;
                                    <input type="hidden" value="" id="pp_id" />
                                </td>
                            </tr>
                            <!--{/if}-->
                            
                            <tr>
                                <th>序号</th>
                                <th>日期</th>
                                <th>价格</th>
                                <th>是否再板</th>
                                <th>备注</th>
                                <th>&nbsp;</th>
                            </tr>
                            <!--{foreach from=$pp_list item=pp name=pp}-->
                            <tr class="data" id="pp_tr_{$pp.pp_id}">
                                <td>{$pp.number}</td>
                                <td>{$pp.datetime}</td>
                                <td>{$pp.price}</td>
                                <td>{$lang.yes_or_no.$pp.again}</td>
                                <td>{$pp.remark}</td>
                                <td align="left">
                                    <input type="hidden" value="{$pp.again}" id="pp_again_{$pp.pp_id}" />
                                    <input type="button" class="btn-1" value="修改" onclick="edit_pp('{$pp.pp_id}')"/> <input type="button" class="btn-1" value="删除" onclick="del_pp('{$pp.pp_id}')"/></td>
                            </tr>
                            <!--{/foreach}-->
                            <tr id="pp_tr_end">
                                <td colspan="6">&nbsp;</td>
                            </tr>
                            <tr>
                                <th>签订合同日期</th>
                                <td align="left"><input type="text" value="{$order.sign_contract_date|date}" name="info[sign_contract_date]" class="input-1" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>确认订单日期</th>
                                <td align="left"><!--{if $order.confirm_date>0}--><input type="text" value="{$order.confirm_date|date}" name="info[confirm_date]" class="input-1" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/><!--{else}-->未确认<!--{/if}--></td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>大 货 布</th>
                                <td align="left"><input type="text" name="info[bulk]" id="bulk" class="input-2" value="{$order.bulk|escape}" /></td>
                                <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>序号</th>
                                <td align="left"><select id="hb_number">
                                    <!--{foreach from=$lang.pp_number item=p key=k}-->
                                        <option value="{$p}">{$p}</option>
                                        <!--{/foreach}--></select></td>
                                <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>大货布寄出日期</th>
                                <td align="left">
                                    <input type="text" value=""  class="input-1" id="hb_send_date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                                </td>
                                <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                             </tr>
                            <tr>
                                <th>大货布批复日期</th>
                                <td align="left" colspan="2">
                                    <input type="text"  class="input-1" id="hb_reply_date"   onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                                    <input type="hidden" id="hb_id" value="" />
                                    <input type="button" onclick="add_huobu()" class="btn-1" value="增加" id="hb_add_bt"/>
                                </td>
                                <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>序号</th>
                                <th>寄出日期</th>
                                <th>批复日期</th>
                                <th>&nbsp;</th>
                                <th>&nbsp;</th><th>&nbsp;</th>
                            </tr>
                            <!--{foreach from=$dahuobu item=huobu}-->
                            <tr class="hbdata" id="hb_tr_{$huobu.id}">
                                <td>{$huobu.number}</td>
                                <td>{$huobu.send_date}</td>
                                <td>{$huobu.reply_date}</td>
                                <td align="left"><input type="button" onclick="edit_huobu('{$huobu.id}')" class="btn-1" value="修改"/> <input type="button" onclick="del_huobu('{$huobu.id}')" class="btn-1" value="删除"/></td>
                                <td>&nbsp;</td><td>&nbsp;</td>
                            </tr>
                            <!--{/foreach}-->
                            <tr  id="hb_tr_end">
                                <td colspan="6">&nbsp;</td>
                            </tr>
                            <tr>
                                <th>查货报告</th>
                                <td align="left" id="order_attachment">
									<!--{foreach from=$order.chahuo_file item=file name=f}-->
									<a href="download.php?id={$file.file_id}" target="_blank">{$file.file_name|escape}</a><a class="pic_del" href="{url app=comupload&act=delete&id=$file.file_id}" onClick="return confirm('{$lang.confirm_del_file}')" title="{$lang.delete}">&nbsp;</a><!--{if !$smarty.foreach.f.last}--><br /><!--{/if}-->
									<!--{/foreach}-->
								</td>
                                <td><input type="button" onclick="upload_docs(8, {$order.order_id});" value="上传附件" class="btn-3"></td>
                                <td></td>
                                <td align="left"><label>
                                    </label></td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>中查日期</th>
                                <td align="left"> <input type="text" value="{$order.middle_check_date|date}" name="info[middle_check_date]" class="input-1" id="middle_check_date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" /> </td>
                                <td>&nbsp;</td>
                                <td></td>
                                <td align="left"><label>
                                    </label></td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>中查问题</th>
                                <td align="left" colspan="5"><textarea name="info[middle_check_problem]" id="middle_check_problem" cols="100" rows="5"></textarea></td>
                            </tr>
                            <tr>
                                <th>尾查日期</th>
                                <td align="left"> <input type="text" value="{$order.last_check_date|date}" name="info[last_check_date]" class="input-1" id="last_check_date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" /> </td>
                                <td>&nbsp;</td>
                                <td></td>
                                <td align="left"><label>
                                    </label></td><td>&nbsp;</td>
                            </tr>
                            <tr>
                                <th>尾查问题</th>
                                <td align="left" colspan="5"><textarea name="info[last_check_problem]" id="last_check_problem" cols="100" rows="5"></textarea></td>
                            </tr>
                            <tr>
                                <th>货前板</th>
                                <td align="left"><input type="text" name="info[before_sample]" id="before_sample" class="input-2" value="{$order.before_sample|escape}" /></td>
                                <th>寄出日期</th>
                                <td align="left">
                                    <input type="text" value="{$order.before_sample_date|date}" name="info[before_sample_date]" class="input-1" id="before_sample_date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                                </td>
                                <th>批复日期</th>
                                <td align="left">
                                    <input type="text" value="{$order.before_sample_reply_date|date}" name="info[before_sample_reply_date]" class="input-1" id="before_sample_reply_date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                                </td>
                            </tr>
                            <tr>
                                <th>问题</th>
                                <td align="left" colspan="5"><label>
                                        <textarea rows="5" cols="100" id="before_sample_problem" name="info[before_sample_problem]">{$order.before_sample_problem}</textarea>
                                    </label></td>
                            </tr>
                            <tr>
                                <th>解决办法</th>
                                <td align="left" colspan="5"><label>
                                        <textarea rows="5" cols="100" id="handle_way" name="info[handle_way]">{$order.handle_way}</textarea>
                                    </label></td>
                            </tr>
                            <tr>
                                <th>大货走货</th>
                                <td align="left"><select name="info[bulk_shipment]" id="bulk_shipment">
                                        <option value="0">否</option>
                                        <option value="1">是</option>
                                    </select></td>
                                <th>走货日期</th>
                                <td align="left">
                                    <input type="text" value="{$order.bulk_shipment_date|date}" name="info[bulk_shipment_date]" class="input-1" id="bulk_shipment_date" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
                                </td>
                                <td>&nbsp;</td>
                                <td align="left">&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="6">
                                    <input type="hidden" value="{$order.order_id}" name="id" />
                                    <input type="submit" value="更新" class="btn-2"/></td>
                            </tr>
                        </tbody></table>
                </form>
            </div>

        </div>
        <script>
            /*
            var order={$order_json};
            $(
            function(){
                $.each(order,function(key,val){
                    if($('#'+key)){
                        if( $('#'+key).attr('nodeName')=='INPUT' && val=='0'){
                            $('#'+key).attr('value','');
                        }
                        else{
                        $('#'+key).attr('value',val);
                        }
                    }
                })
                $("input[name='order_id']").attr('value',order.order_id);
                // brand_change(order.brand_id,order.buyer_id,order.merchandiser_id);
            }
        );*/
   
            var order={
                bulk :'{$order.bulk}',
                middle_check :'{$order.middle_check}',
                last_check :'{$order.last_check}',
                before_sample :'{$order.before_sample}',
                bulk_shipment :'{$order.bulk_shipment}',
                ref_sample :'{$order.ref_sample}'
            };
            $.each(order,function(key,val){
                //alert(key+'='+val)
                $('#'+key).attr('value',val);
            });
             /*
            $('#status_form').bind('submit',function(){
                var url=$(this).attr('action')+'&ajax=1';
                $.ajax({
                    url:url,
                    type:'post',
                    dataType:'json',
                    data:$('#status_form').serialize(),
                    success:function(json){
                        if(json.done){
                            $.alert(json.msg);
                        }else{
                            $.alert(json.msg);
                        }
                    },
                    error:function(r,s,e){alert(e)}
                });
                return false;
            });
           */
            function addPP(){
                pp_id=$('#pp_id').val();
                if($('#pp_price').val()=='' || $('#pp_date').val()=='' || $('#pp_zaiban').val()==''){
                    alert('请填写完整');
                    return false;
                }
                var url='index.php?app=order&act=addPP&order_id={$order.order_id}&ajax=1&pp_id='+pp_id;
                $.ajax({
                    url:url,
                    type:'post',
                    dataType:'json',
                    data:{'price':$('#pp_price').val(),'date':$('#pp_date').val(),'again':$('#pp_zaiban').val(),'number':$('#pp_number').val(),'remark':$('#pp_remark').val(),'order_id':'{$order.order_id}'},
                    success:function(json){
                        //json={"done":true,"msg":" 添加完成","retval":{"price":"22","again":"0","datetime":"2011-03-02"}};
                        //json=eval('(' + json + ')');;
                        if(json.done){
                            var item=json.retval;
                            var s='<tr class="data" style="background-color: rgb(244, 248, 250);" id="pp_tr_'+item.pp_id+'">';
                            s2= '<td>'+item.number+'</td>';
                            s2+= '<td>'+item.datetime+'</td>';
                            s2+= '<td>'+item.price+'</td>';
                            s2+= '<td>'+(item.again=='1'?'{$lang.yes}':'{$lang.no}')+'<input type="hidden" value="'+item.again+'" id="pp_again_'+item.pp_id+'"></td>';
                            s2+= '<td>'+item.remark+'</td>';
                            s2+= '<td align="left"><input type="button" class="btn-1" value="修改" onclick="edit_pp(\''+item.pp_id+'\')"/> <input type="button" class="btn-1" value="删除" onclick="del_pp(\''+item.pp_id+'\')"/></td>';
                            s3= '</tr>';
                            if(pp_id){
                                $('#pp_tr_'+pp_id).html(s2);
                            }
                            else{
                                $('#pp_tr_end').before(s+s2+s3);
                            }
                            $('#pp_date,#pp_price,#pp_remark,#pp_id').val('');
                            $('#pp_add_bt').val('添加');
                            if(item.again==1){
                                $('.addpp_tr').hide();
                            }
                        }else{
                            $.alert(json.msg);
                        }
                    },
                    error:function(r,s,e){alert(r+s+e)}
                });
                return false;
            }
            function edit_pp(id){
                $('#pp_id').val(id);
                var tds=$('#pp_tr_'+id).find('td');
                $('#pp_add_bt').val('更新');
                $('#pp_number').val($(tds[0]).html());
                $('#pp_date').val($(tds[1]).html());
                $('#pp_price').val($(tds[2]).html());
                $('#pp_zaiban').val($('#pp_again_'+id));
                $('#pp_remark').val($(tds[4]).html());
                return;
            }
            function del_pp(pp_id){
                $.getJSON('index.php?app=order&act=del_pp&ajax=1&pp_id='+pp_id,
                    function(json){
                        if(json.done){
                            $('#pp_tr_'+pp_id).remove();
                        }
                        else{
                            alert(json.msg);
                        }
                    }
                );
            }

            function add_huobu(){
                id=$('#hb_id').val();
                if($('#hb_send_date').val()=='' || $('#hb_replay_date').val()==''){
                    alert('请填写完整');
                    return false;
                }
                var url='index.php?app=order&act=add_huobu&order_id={$order.order_id}&ajax=1&id='+id;
                $.ajax({
                    url:url,
                    type:'post',
                    dataType:'json',
                    data:{'send_date':$('#hb_send_date').val(),'reply_date':$('#hb_reply_date').val(),'number':$('#hb_number').val(),'order_id':'{$order.order_id}'},
                    success:function(json){
                        //alert(json);return;
                        if(json.done){
                            var item=json.retval;
                            var s='<tr class="hbdata" style="background-color: rgb(244, 248, 250);" id="hb_tr_'+item.id+'">';
                            s2= '<td>'+item.number+'</td>';
                            s2+= '<td>'+item.send_date+'</td>';
                            s2+= '<td>'+item.reply_date+'</td>';
                            s2+= '<td align="left"><input type="button" class="btn-1" value="修改" onclick="edit_huobu(\''+item.id+'\')"/> <input type="button" class="btn-1" value="删除" onclick="del_huobu(\''+item.id+'\')"/></td>';
                            s2+='<td>&nbsp;</td><td>&nbsp;</td>';
                            s3= '</tr>';
                            if(id){
                                $('#hb_tr_'+id).html(s2);
                            }
                            else{
                                $('#hb_tr_end').before(s+s2+s3);
                            }
                            $('#hb_send_date,#hb_reply_date,#hb_id').val('');
                            $('#hb_add_bt').val('添加');
                        }else{
                            $.alert(json.msg);
                        }
                    },
                    error:function(r,s,e){alert(r+s+e)}
                });
                return false;
            }
            function edit_huobu(id){
                $('#hb_id').val(id);
                var tds=$('#hb_tr_'+id).find('td');
                $('#hb_add_bt').val('更新');
                $('#hb_number').val($(tds[0]).html());
                $('#hb_send_date').val($(tds[1]).html());
                $('#hb_reply_date').val($(tds[2]).html());
                return;
            }
            function del_huobu(id){
                $.getJSON('index.php?app=order&act=del_huobu&ajax=1&id='+id,
                    function(json){
                        if(json.done){
                            $('#hb_tr_'+id).remove();
                        }
                        else{
                            alert(json.msg);
                        }
                    }
                );
            }
        </script>
        <script language="JavaScript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
    </body>
</html>